import React, { PropTypes, Component } from 'react'
import Banner from './Banner'
import Component2 from './Component2'

class Page extends Component {
 constructor(props, context) {
    super(props, context)
    this.state={

      dialogImgOpen:false
    }

  }

  genSetions(){
     let { components,actions }=this.props
      return components.map((cpt)=>{
        switch (cpt.id){
          case 1:{
           return <Banner
                   key={cpt.positionId}
                   component={cpt}
                   actions={actions}
                   positionId={cpt.positionId}
                   handleDialogImgToggle={this.props.handleDialogImgToggle}
                   handleWidgetMenuShow={this.props.handleWidgetMenuShow}
           /> 
           } 
          case 2:{
           return <Component2
                   key={cpt.positionId}
                   component={cpt}
                   actions={actions}
                   positionId={cpt.positionId}
                   handleDialogImgToggle={this.props.handleDialogImgToggle}
                   handleWidgetMenuShow={this.props.handleWidgetMenuShow}
           /> 
          
          }
        }




      })
    
  }
  handleDialogClose(){

  }
  render() {

    return (
      <div className="sections">
        {this.genSetions()}
      </div>
     
    )
  }
}

Page.propTypes = {
  components:PropTypes.array.isRequired
}

export default Page
